﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BBPA.Admin.Sys.Orders.Buying
{
    public partial class Form_Pause : FormPage
    {
        BLL.Orders bll = new BLL.Orders();
        Model.Orders model = new Model.Orders();
        //
        BLL.Orders_State_Log bllOrders_State_Log = new BLL.Orders_State_Log();
        protected void Page_Load(object sender, EventArgs e) { }
        /// <summary>
        /// 初始化本页Model
        /// </summary>
        public override void Page_Load_DefaultModel() { model = bll.GetModel(Master.id); }
        /// <summary>
        /// 初始化表单
        /// </summary>
        public override void Form_Default() { }
        /// <summary>
        /// 绑定表单数据【修改时用】
        /// </summary>
        public override void Form_Bind() { }
        /// <summary>
        /// 提交
        /// </summary>
        public override void Form_Submit()
        {
            string Description = tb_Description.Text;

            if (
                Master.noEmpty(Description, "[暂停原因]必须填写")
                )
            {
                model.State = (int)EnumHelper.OrdersState.BuyPause;
                bll.Update(model);
                BLL.User_Operate_Log.Add(Security.GetCurrentUserID(), EnumHelper.TableName.Orders, Master.id, EnumHelper.OperateType.Update, "暂停采购");
                //
                Model.Orders_State_Log modelLog = new Model.Orders_State_Log();
                modelLog.OrdersID = Master.id;
                modelLog.State = (int)EnumHelper.OrdersState.BuyPause;
                int LogID = bllOrders_State_Log.Add(modelLog);
                BLL.User_Operate_Log.Add(Security.GetCurrentUserID(), EnumHelper.TableName.Orders_State_Log, LogID, EnumHelper.OperateType.Add, "暂停采购");
                Master.SubmitOK("订单成功暂停");
            }
        }
    }
}